package com.youxue.service;

import com.youxue.dao.CommentMapper;
import com.youxue.entity.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 15c on 2018/1/20.
 */
@Service("comment")
public class CommentServiceImpl implements CommentService {
    @Autowired
    CommentMapper commentMapper;

    @Override
    public int addComment(Comment comment) {
        return commentMapper.insertSelective(comment);
    }

    @Override
    public List<Comment> showAClassAllCommentByPage(Integer startPos,Integer pageSize,Integer commentClassId) {
        return commentMapper.selectAClassAllCommentByPage(startPos,pageSize,commentClassId);
    }

    @Override
    public int showAClassAllCommentCount(Integer commentClassId) {
        return commentMapper.SelectAClassAllCommentCount(commentClassId);
    }

    @Override
    public Comment showACommentInfo(Integer commentId) {
        return commentMapper.selectACommentInfo(commentId);
    }
    @Override
    public int deleteAComment(Integer commentId) {
        return commentMapper.deleteByPrimaryKey(commentId);
    }

    @Override
    public int showUserIdACommentForDelete(Integer commentId) {
        return commentMapper.selectUserIdACommentForDelete(commentId);
    }

    @Override
    public List<Integer> showAllComment() {
        return commentMapper.selectAllComment();
    }

    @Override
    public double sumAClassTotalScore(Integer classId) {
        return commentMapper.selectSumAClassTotalScore(classId);
    }
}
